import java.rmi.*;
import java.rmi.registry.*;
import java.util.ArrayList;
import java.net.*;

public class TestClient {
	static public void main(String args[]) {
		ReceiveMessageInterface rmiServer;
		Registry registry;
		String serverAddress = args[0];
		String serverPort = args[1];
		String text = args[2];

		System.out.println("sending " + text + " to " + serverAddress + ":"
				+ serverPort);
		try {
			registry = LocateRegistry.getRegistry(serverAddress, (new Integer(
					serverPort)).intValue());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServer"));
			System.out.println(rmiServer.falha());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServertemp"));			
			System.out.println(rmiServer.restart());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServer"));

			Teatro teatro = rmiServer.getTheater("teatro1");
			if (teatro != null)
				System.out.println("ID: " + teatro.id + "\ncom nome: "
						+ teatro.nome);

		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}
}
